package com.service.impl;

import com.bean.entity.ChainType;
import com.bean.vo.ChainTypeQueryVo;
import com.dao.ChainTypeMapper;
import com.service.ChainTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 产品规格管理实现
 */
@Service
public class ChainTypeServiceImpl implements ChainTypeService {
    @Autowired
    private ChainTypeMapper ctm;

//    @Override
//    public List<ChainTypeQueryVo> Query(ChainTypeQueryVo ctv) {
//        int count = ctm.selectCount(ctv);
//        ctv.setPage_size(count);
//        List<ChainTypeQueryVo> list = ctm.selectByPage(ctv);
////        List list = ctm.select(ctv);
//        return list;
//    }

    @Override
    public List<ChainTypeQueryVo> QueryAll(ChainTypeQueryVo ctv) {
        List<ChainTypeQueryVo> list = ctm.selectByPage(ctv);
        return list;
    }

    @Override
    public List<ChainTypeQueryVo> Query() {
        Map<String,Object>map = new HashMap<>();
        List<ChainTypeQueryVo> list = ctm.selectByPage(map);
        return list;
    }

    @Override
    public int update(ChainTypeQueryVo ctv) {
        ChainType ct = ctv.getCt();
        int count = ctm.update(ct);
        return count;
    }

    @Override
    public int delete(ChainTypeQueryVo ctv) {
        int count = ctm.delete(ctv);
        return count;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int add(ChainTypeQueryVo ctv) {
        ChainType ct = ctv.getCt();
        int count = ctm.insertMain(ct);
        return count;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int fakeDelete(ChainTypeQueryVo ctv) {
        int count = ctm.fakeDelete(ctv);
        return count;
    }

    @Override
    public int count(ChainTypeQueryVo ctv) {
        int count = ctm.selectCount(ctv);
        return count;
    }
}
